<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	pageContext.setAttribute("path",request.getContextPath());
%>
<script type="text/javascript">
	$(document).ready(function(){
		$("ul li:eq(1)").addClass("active");
	});

	// 删除管理员之弹窗确认
	function delAdmin(id,username) {
		if (confirm("确定要删除管理员"+username+"吗?")) {
			window.location="${path}/admin/del/"+id;
			return true;
		}
		return false;
	}
</script>
<div class="data_list">
	<div class="data_list_title">
		管理员管理
	</div>
	<form name="searchForm" action="${path}/admin/show" class="form-search" method="get"  style="padding-bottom: 0px">
		<c:if test="${sessionScope.admin.role.equals('超级管理员')}">
			<button class="btn btn-success" type="button" style="margin-right: 50px;" onclick="javascript:window.location='${path}/admin/add'">添加管理员</button>
		</c:if>
		<span class="data_search">
			<select id="searchType" name="searchType" style="width: 120px;">
				<option value="username">管理员名称</option>
				<option value="name">管理员姓名</option>
				<option value="email">电子邮箱</option>
			</select>&nbsp;
			<input id="s_Text" name="s_Text" type="text"  style="width:120px;height: 20px;" class="input-medium search-query" value="">&nbsp;
			<button type="submit" class="btn btn-info" onkeydown="if(event.keyCode==13) searchForm.submit()">搜索</button>
		</span>
	</form>
	<div>
		<table class="table table-striped table-bordered table-hover datatable">
			<thead style="background:#e0effd">
				<tr>
			    	<th>编号</th>
					<th>管理员名称</th>
					<th>管理员姓名</th>
					<th>电子邮箱</th>
					<th>角色</th>
					<c:if test="${sessionScope.admin.role.equals('超级管理员')}">
						<th>操作</th>
					</c:if>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${adminList}" var="admin">
					<tr>
						<td>${admin.id}</td>
						<td>${admin.username}</td>
						<td>${admin.name}</td>
						<td>${admin.email}</td>
						<td>${admin.role}</td>
						<c:if test="${sessionScope.admin.role.equals('超级管理员')}">
							<td>
								<button class="btn btn-mini btn-info" type="button" onclick="javascript:window.location='${path}/admin/edit/${admin.id}'">修改</button>&nbsp;
								<button class="btn btn-mini btn-danger" type="button" onclick="delAdmin('${admin.id}','${admin.username}')">删除</button>
							</td>
						</c:if>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>
	<div align="center"><font color="red">获取到${adminList.size()}条数据</font></div>
</div>